#include<stdio.h>
#include<stdlib.h>
typedef struct number
{
    int data;
    struct number *ptr;
}num;
void shownum(num* head)
{
    num* current=head;
    printf("The new list is:");
    while(current->ptr!=NULL)
    {
        printf("%d ",current->data);
        current=current->ptr;
    }
    printf("%d\n",current->data);
    
    
}

void delenum(num *head)
{
    num*current=head;
    while(current->ptr!=NULL)
    {
        current=current->ptr;
        free(head);
        head=current;
    }
}
num*  addnum(num *head,int adddata )
{
    num *current=head;
    num *add=(num*)malloc(sizeof(num));
    if(head==NULL)
    {
        head=add;
    }
   else
   {
        while(current->ptr!=NULL)
        {
            current=current->ptr;
        }
        current->ptr=add;
    }
    add->data=adddata;
    add->ptr=NULL;
    return head;
}

num* searchhead(num* head,int x)
{
    num *tem=head;
    if(x==1)
    {
        return tem;
    }
    else{
        for(;x>2;x--)
        {
            tem=tem->ptr;
        }
        return tem;
    }
    
}

num* searchtie(num* head,int x)
{
    num *tem=head;
    for(;x>1;x--)
    {
        tem=tem->ptr;
    }
    return tem;
    
}

num *swapnum(num*head,int x,int y,int m,int n)
{
    
    num* head1,*tie1,*head2,*tie2;
    head1=searchhead(head,x);
    tie1=searchtie(head,y);
    head2=searchhead(head,m);
    tie2=searchtie(head,n);

    if(x==1)
    {
       if((y+1)==m)
        {
            num *tem1,*tem2;
            tem1=head;
            tem2=tie2->ptr;
            head=head2->ptr;
            tie2->ptr=tem1;
            tie1->ptr=tem2;
        }else{
                 num*tem2;
                 tem2=tie2->ptr;
                 head=head2->ptr;
                 tie2->ptr=tie1->ptr;
                 head2->ptr=head1;
                 tie1->ptr=tem2;
        }
      

        
    }else{
        if((y+1)==m)
        {
            num *tem1,*tem2;
            tem1=head1->ptr;
            tem2=tie2->ptr;
            head1->ptr=head2->ptr;
            tie2->ptr=tem1;
            tie1->ptr=tem2;
        }
        else
        {
            num*tem1,*tem2;
            tem1=head1->ptr;
            tem2=tie2->ptr;
            head1->ptr=head2->ptr;
            tie2->ptr=tie1->ptr;
            head2->ptr=tem1;
            tie1->ptr=tem2;
        }
    }
    return head;

}

int main()
{
    int a;
    int m,n,x,y;
    num* head=NULL;
    while(1)
    {
        scanf("%d",&a);
        if(a==-1)
        {
            break;
        }
        else{
           head=addnum(head,a);
        }
    }
    scanf("%d%d%d%d",&x,&y,&m,&n);
    head=swapnum(head,x,y,m,n);
    shownum(head);
    delenum(head);

      
   
   
    
    
    return 0;
}